<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<!-- 导入jquery核心类库 -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/default.css">	
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
<script
	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>
		
<script type="text/javascript">
	$(function(){
		$("body").css({visibility:"visible"});
		//提交表单
		
		 $('#save').click(function(){var flag=true;
			$('#sform :input').each(function(){
				if(this.value==-1 || this.value==null||this.value==""){
					flag=false;
					
				}
			});
				// 校验
				if(flag){
					// 1 、获得form 数据
					var params = $('#sform').serialize();
					// 2、将数据发送给服务器 
					$.post("${pageContext.request.contextPath}/page.processOrderBack.ashx", params , function(data){
						//alert(data)
						
						if(data.status == "1"){
							// 成功
							$.messager.alert('消息','操作成功 ','info', function(){
								location.href="${pageContext.request.contextPath}/page.orderback.ashx"
							});
							
						
						}else if(data.status==("nonentity")){
							$.messager.alert('消息','库存中未找到SN为"<font color=red>'+data.RSN+'</font>"状态为"<font color=red>已出库</font>"的E尺','info');
						}else if(data.status==("conflict")){
							$.messager.alert('消息','您输入了 重复的 SN号：'+data.RSN+'<br>Ctrl+F在网页上查找一下'+data.RSN+'吧！','info');
						}else if(data.status=="notbelong"){
							$.messager.alert('消息',data.RSN+'不属于当前客户','info');
						}else{
							data = new String(data);
							if(data.charAt(0)=='<'){
								$.messager.alert('消息','登录超时或无权限','info');
							}
						}
							
						
							
					});
				}else{
					$.messager.alert("提示", "请检查输入项是否有遗漏未输入","warnning");
				}
				
			});	
	});
	
	
	
	$(document).ready(function(){
		$('#opcode_1').focus();
		
		//动态生成表单
      	var a = $("#oOPNumber").html();
    	for(i=0;i<a-1;i++){
    		alert(111)
    	
           var _len = $("#tab tr").length;        
           $("#tab").append("<tr><td>产品条码:</td>"
           						 +"<td><input type='text' name='opcode_"+_len+"' id='opcode_"+_len+"' class='easyui-textbox' /></td>" 
           						 +"<td>去向:</td>" 
           						
           						+"<td><select  name='gowhere_"+_len+"' id='gowhere_"+_len+"' ><option value='-1'></option><option value ='0'>&nbsp;转入库存&nbsp;</option><option value ='4'>&nbsp;报废&nbsp;</option></select></td></tr>");             
    	}
	}); 
	
	window.onload=function(){
		//基本信息格式化
		$("#oDealTime").html(formatterDate($("#oDealTime").html()));
		$("#oITime").html(formatterDate($("#oITime").html()));
		$("#oIsDone").html($("#oIsDone").html()=="false"?"未处理":"已处理");
		$("#tr_oBType").html($("#tr_oBType").html()=="1"?"客户退回":"员工自用退回");
	}
	function formatterDate(value){
		if(value==''||null==value){
			return '';
		}
		var now = new Date(parseInt(value) * 1000);  
		var year=now.getYear()+1900; 
		var month=now.getMonth()+1; 
		var date=now.getDate(); 
		var hour=now.getHours(); 
		var minute=now.getMinutes();
		minute= (minute > 9) ? minute=minute : minute='0'+minute;
		//var second=now.getSeconds(); 
		return year+"-"+month+"-"+date+" "+hour+":"+minute; 
	}
</script>	
</head>

<body class="easyui-layout" style="visibility:hidden;">
	<div region="north" style="height:31px;overflow:hidden;" split="false" border="false" >
		<div class="datagrid-toolbar">
			<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true" >保存</a>
			
		</div>
	</div>
    <div region="center" style="overflow:auto;padding:5px;" border="false">
        
         <table class="table-edit"  width="95%" align="center">
           		<tr class="title"><td colspan="6">基本信息</td></tr>
           		
	           	<tr>
	           		<td>入库时间:</td>
	           		<td id="oDealTime">${ob.oBTime}</td>
					<td>入库数量:</td>
					<td id="oOPNumber">${ob.oBPNumber}</td>
				</tr>  	 	<tr>
	           		<td>处理状态</td>
					<td id="oIsDone">${ob.oBIsDone}</td>
					<td>经手人:</td>
					<td>${ob.oBKuGuanName}</td>
				</tr>  	<tr>
	           		<td>申请人:</td>
	           		<td >${ob.oBProposerName}</td>
					<td>备注:</td>
	           		<td >${ob.oBReMark}</td>
				</tr> <tr>
	           		<td>退回原因:</td>
	           		<td id="tr_oBType">${ob.oBType}</td>
					<td>客户名称:</td>
	           		<td >${ob.oBBuyerName}</td>
				</tr> 
			</table>
           <form id="sform">  
           <input name="oBId" id="oBId" type="hidden" value="${ob.oBId}" />
			<input name="oBPNumber" id="oBPNumber" type="hidden" value="${ob.oBPNumber}" />
			<input name="oBProposerId" id="oBProposerId" type="hidden" value="${ob.oBProposerId}" />
			<input name="oBBuyerId" id="oBBuyerId" type="hidden" value="${ob.oBBuyerId}" />
			<input name="oBType" id="oBType" type="hidden" value="${ob.oBType}" />

			<table id="tab" class="table-edit"  width="95%" align="center">
			
				<tr class="title"><td colspan="6">产品信息</td></tr>
				 <tr>	<td>产品条码:</td>
						<td><input type="text" name="opcode_1" id="opcode_1"/></td>
						<td>去向:</td>
           				<td><select   name="gowhere_1" id="gowhere_1" ><option value='-1'></option><option value ='0'>&nbsp;转入库存&nbsp;</option><option value ='4'>&nbsp;报废&nbsp;</option></select></td>           
				</tr>
	           
	         </table> 
	  	
	    
				
         
     </form> 
	</div>
</body>
</html>